﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Media.Animation;

namespace JustPlus
{
    /// <summary>
    /// HelpPanel.xaml 的交互逻辑
    /// </summary>
    public partial class HelpPanel : UserControl
    {
        private int helppage = 1;
        private int helpcount = 4;
        private int lasthelppage = 1;//更换帮助页之前的帮助页码
        private Image[] imagebut;
        public HelpPanel()
        {
            InitializeComponent();
            imagebut = new Image[4] { image3, image4, image5, image6 };
        }

        private void Grid_MouseLeave(object sender, MouseEventArgs e)
        {
            MainWindow mwnd = (MainWindow)Application.Current.MainWindow;
            mwnd.stackPanel1.Children.Clear();
            mwnd.stackPanel1.Children.Add(mwnd.stackPanel2);
            mwnd.stackPanel1.Children.Add(mwnd.stackPanel3);
        }

        //下一个帮助项
        private void image7_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            lasthelppage = helppage;
            helppage = helppage + 1;
            if (helppage <= helpcount)
            {
                UpdateHelp();
            }
            else
            {
                helppage = helppage - 1;
            }
            
        }

        //上一个帮助项
        private void image2_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            lasthelppage = helppage;
            helppage = helppage - 1;
            if (helppage >= 1)
            {
                UpdateHelp();
            }
            else
            {
                helppage = helppage + 1;
            }
        }

        private void grid_Loaded(object sender, RoutedEventArgs e)
        {
            Storyboard sb = (Storyboard)Resources["OpacityInc"];
            sb.Begin();
        }

        private void UpdateHelp()
        {
            image1.Source = new BitmapImage(new Uri(@"/JustPlus;component/Images/help" + helppage.ToString() + @".png", UriKind.Relative));
            imagebut[lasthelppage - 1].Source = new BitmapImage(new Uri(@"/JustPlus;component/Images/Unselected.png", UriKind.Relative));
            imagebut[helppage - 1].Source = new BitmapImage(new Uri(@"/JustPlus;component/Images/selected.png", UriKind.Relative));
            Storyboard sb0 = (Storyboard)Resources["OpacityDec"];
            sb0.Begin();
            Storyboard sb = (Storyboard)Resources["OpacityInc"];
            sb.Begin();
        }

        private void image3_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            lasthelppage = helppage;
            helppage = 1;
            UpdateHelp();
        }

        private void image4_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            lasthelppage = helppage;
            helppage = 2;
            UpdateHelp();
        }

        private void image5_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            lasthelppage = helppage;
            helppage = 3;
            UpdateHelp();
        }

        private void image6_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            lasthelppage = helppage;
            helppage = 4;
            UpdateHelp();
        }
    }
}
